/*
此题用来说明，内存存储的大端和小端模式
*/

#include<stdio.h>

int main(void)
{
    /*
    printf("%d %d %d %d %d\n",sizeof(char),sizeof(short),sizeof(int),sizeof(long),sizeof(long long));
    int a=1;
    printf("%d\n",a<<32);
    */


    /*//part 1
    int c=1;
    if(*(char*)&c==1)
    {
        printf("little endian\n");
    }
    else
        printf("big endian\n");
    //*/


    ///*//part 2
    union
    {
        short n;
        char c[sizeof(short)];
    }un;

    un.n=0x0102;

    if(un.c[0]==1 && un.c[1]==2)
    {
        printf("big endian\n");
    }
    else if(un.c[0]==2 && un.c[1]==1)
    {
        printf("little endian\n");
    }
    else
    {
        printf("error");
    }
    //*/
}
